# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Magicloud <magiclouds@gmail.com>
pkgname=minikube
pkgver=1.34.0
pkgrel=0
pkgdesc="Tool that makes it easy to run Kubernetes locally"
url="https://github.com/kubernetes/minikube"
license="Apache-2.0"
arch="all !s390x !riscv64 !loongarch64" # blocked by libvirt
arch="$arch !x86 !armhf !armv7 !ppc64le !aarch64" # FTBFS (kvm2 driver)
makedepends="go bash libvirt-dev"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	docker-machine-driver-kvm2:_kvm2_driver
	"
source="https://github.com/kubernetes/minikube/archive/v$pkgver/minikube-$pkgver.tar.gz
	skip-amd64-only-test.patch
	"
options="net"

export GOPATH="$srcdir"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make out/minikube out/docker-machine-driver-kvm2

	cd out
	 ./minikube completion bash > $pkgname.bash
	 ./minikube completion fish > $pkgname.fish
	 ./minikube completion zsh > $pkgname.zsh
}

check() {
	TESTSUITE=unittest make test
}

package() {
	cd out
	install -Dm755 minikube "$pkgdir"/usr/bin/minikube
	install -Dm755 docker-machine-driver-kvm2 "$pkgdir"/usr/bin/docker-machine-driver-kvm2

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

_kvm2_driver() {
	pkgdesc="minikube-maintained KVM driver for docker-machine"

	amove usr/bin/docker-machine-driver-kvm2
}

sha512sums="
bc70f533bf7d0a9cf7eb1a09d71b05d6eacddf954d328e3f2a8221f5e175be95d9d260a61d901d85e777af9939a8a02ccf81e74700453bddd15e7b3f59e50b55  minikube-1.34.0.tar.gz
2eccb63b0905791968dec95f8f758da12632a8530c6db600648f2a190b23dd363d1a3c717488fc4e36f9082346c053eb9cf2ed00f65d14744e3fe9606dc32ddd  skip-amd64-only-test.patch
"
